(function ($) {
			
	$.fn.carouselize = function ( settings ) {
		
		if ( this.size() > 0 ) {
		
			// this == carousel element - to which applied this functionality
			var carousel = this;

			this.settings = {
				"leftArrow": ".arr-left",
				"rightArrow": ".arr-right"
			};
			$.extend(this.settings, settings);
		
			// dom elements
			this.container = carousel.find('.images');
			this.images = carousel.find('img');
		
			// sizes
			this.image = {
				width: this.images.width()
			};					
			this.size = this.images.size();
			this.container.css("width", (this.size*this.image.width)+"px");
		
			this.current = 1;
		
			this.button = {
		
				right: carousel.find('.arr-right'),
				left: carousel.find('.arr-left'),				
		
				update: function () {
				
					if ( carousel.current == 1 ) {
				
						carousel.button.left.addClass("disabled");
					}
					else if ( carousel.current == carousel.size ) {
				
						carousel.button.right.addClass("disabled");
					}
					else {
					
						var disabled = carousel.find(".disabled");
					
						if (disabled) {
						
							disabled.removeClass("disabled");
						}
					}
				}
			};
		
			this.button.update();			
		
			// Create bullets elemnt
			var bullets = $("<ul />").attr({
				"id": "bullets"
			});
		
			carousel.append(bullets);
		
			for ( i=0; i < this.size; i++) {
				bullets.append($("<li />"));
			}			
	
			var currentBullet = bullets.find('li').first();
			currentBullet.addClass("current");
	
			this.right = function () {
			
				if ( carousel.current < carousel.size ) {
				
					carousel.container.anim({translateX: '-'+ carousel.image.width * carousel.current +'px'}, 0.25, 'linear');
					carousel.current++;
				
					currentBullet.removeClass("current");
					currentBullet = currentBullet.next();
					currentBullet.addClass("current");						
				}
			
				carousel.button.update();
			
			};

			this.left = function () {

				if ( carousel.current > 1 ) {
				
					carousel.current--;
					carousel.container.anim({translateX: '-'+ carousel.image.width * (carousel.current-1) +'px'}, 0.25, 'linear');
				
					currentBullet.removeClass("current");
					currentBullet = currentBullet.prev();
					currentBullet.addClass("current");							
				}
			
				carousel.button.update();
			};
		
			this.button.right.bind("click", this.right);
			this.button.left.bind("click", this.left); 
		
		} //end of if the carousel exist
	};
        
})(window.Zepto);		